home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Original Code / Tree View and List View / SplitThreeFrames / SplitThreeFrames.cs next >
Encoding:
Text File  |  2001-01-15  |  2.2 KB  |  67 lines

  1. //-----------------------------------------------
  2. // SplitThreeFrames.cs ⌐ 2001 by Charles Petzold
  3. //-----------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class SplitThreeFrames: Form
  9. {
  10.      public static void Main()
  11.      {
  12.           Application.Run(new SplitThreeFrames());
  13.      }
  14.      public SplitThreeFrames()
  15.      {
  16.           Text = "Split Three Frames";
  17.  
  18.           Panel panel      = new Panel();
  19.           panel.Parent     = this;
  20.           panel.Dock       = DockStyle.Fill;
  21.  
  22.           Splitter split1  = new Splitter();
  23.           split1.Parent    = this;
  24.           split1.Dock      = DockStyle.Left;
  25.  
  26.           Panel panel1     = new Panel();
  27.           panel1.Parent    = this;
  28.           panel1.Dock      = DockStyle.Left;
  29.           panel1.BackColor = Color.Lime;
  30.           panel1.Resize   += new EventHandler(PanelOnResize);
  31.           panel1.Paint    += new PaintEventHandler(PanelOnPaint);
  32.  
  33.           Panel panel2     = new Panel();
  34.           panel2.Parent    = panel;
  35.           panel2.Dock      = DockStyle.Fill;
  36.           panel2.BackColor = Color.Blue;
  37.           panel2.Resize   += new EventHandler(PanelOnResize);
  38.           panel2.Paint    += new PaintEventHandler(PanelOnPaint);
  39.  
  40.           Splitter split2  = new Splitter();
  41.           split2.Parent    = panel;
  42.           split2.Dock      = DockStyle.Top;
  43.  
  44.           Panel panel3     = new Panel();
  45.           panel3.Parent    = panel;
  46.           panel3.Dock      = DockStyle.Top;
  47.           panel3.BackColor = Color.Tan;
  48.           panel3.Resize   += new EventHandler(PanelOnResize);
  49.           panel3.Paint    += new PaintEventHandler(PanelOnPaint);
  50.  
  51.           panel1.Width  = ClientSize.Width  / 3;
  52.           panel3.Height = ClientSize.Height / 3;
  53.      }
  54.      void PanelOnResize(object obj, EventArgs ea)
  55.      {
  56.           ((Panel) obj).Invalidate();
  57.      }
  58.      void PanelOnPaint(object obj, PaintEventArgs pea)
  59.      {
  60.           Panel    panel = (Panel) obj;
  61.           Graphics grfx  = pea.Graphics;
  62.  
  63.           grfx.DrawEllipse(Pens.Black, 0, 0, 
  64.                            panel.Width - 1, panel.Height - 1);
  65.      }
  66. }
  67.